package com.lzh.face;

public class Point {
	private double x;
	private double y;
	
	public Point(double x, double y) {
		super();
		this.x = x;
		this.y = y;
	}
	public double getX() {
		return x;
	}
	public void setX(double x) {
		this.x = x;
	}
	public double getY() {
		return y;
	}
	public void setY(double y) {
		this.y = y;
	}
	
	public static Point MiddlePoint(Point p1, Point p2){
		return new Point((p1.x+p2.x)/2,(p1.y+p2.y)/2);
	}
	
	public static double distance(Point p1, Point p2) {
		return Math.sqrt(Math.pow(p1.getX() - p2.getX(), 2)
				+ Math.pow(p1.getY() - p2.getY(), 2));
	}
	
	public static double distanceX(Point p1, Point p2) {
		return Math.abs(p1.x-p2.x);
	}
	
	public static double distanceY(Point p1, Point p2) {
		return Math.abs(p1.y-p2.y);
	}
	
	public String toString(){
		return "x:"+this.getX()+" y:"+this.getY();
	}
}
